<template>
	<el-form  :model="distributeform" label-width="80px">
		<el-form-item label="病人编号">
			<el-input v-model="distributeform.patientId"></el-input>
		</el-form-item>
		<el-form-item label="食物编号">
			<el-input v-model="distributeform.foodId"></el-input>
		</el-form-item>
		<el-form-item label="供应时间">
			<el-date-picker
			     v-model="distributeform.supplyDay"
			     type="datetime"
				 value-format="yyyy-MM-dd HH:mm:ss"
			     placeholder="选择日期">
			   </el-date-picker>
		</el-form-item>
		<el-form-item label="供应周天">
			<el-input v-model="distributeform.supplyWeekday"></el-input>
		</el-form-item>
		<el-button type="primary" @click="doDistrEdit">提交</el-button>
	</el-form>

</template>

<script>
	export default{
		name:'DistributeEdit',
		props:{
			formData:{
				type:Object,
				default:()=>({})
			},
			editVisible:{
				type:Boolean
			}
		},
		data(){
			return{
				distributeform:{
					patientId:'',
					foodId:'',
					supplyDay:'',
					supplyWeekday:''
				}
			}
		},
		mounted(){
			this.distributeform=this.formData;
		},
		methods:{
			doDistrEdit(){
				this.postRequest("/distribute/update",this.distributeform).then(resp=>{
					if(resp){
						this.$emit("update:editVisible",false);
					}else{
						this.$message.error({message:'编辑失败'});
					}
				})
			}
		},
		watch:{
			formData:{
				deep:true,
				handler(newVal,oldVal){
					this.distributeform=newVal
				}
			}
		}
	}
</script>

<style>
</style>
